import { BroadCastCall } from "../broadCast/BroadCastCall";
import { MessageBlock } from "../../../../Framework/MQ/MessageBlock";
import { SBagIndex } from "../../../../Message/Game/SBagIndex";
import { NetDispatcher } from "../../../mvc/core/NetDispatcher";
import { ServerCommand } from "../../mvc/ServerCommand";
import { Cache } from "../../cache/Cache";
import { ItemData } from "../../resource/info/ItemData";
import { EPlayerItemPosType } from "../../../../Message/Public/EPlayerItemPosType";
//class PackIndexCommand
    
    export  class PackIndexCommand extends BroadCastCall
    {
        constructor(arg1: Object)
        {
            super(arg1);
            return;
        }

        public /* override */ call(arg1: MessageBlock): void
        {
            var loc1=arg1.messageBase as SBagIndex;
            var loc2=loc1.posType;
            switch (loc2) 
            {
                case 0:
                {
                    _cache.pack.backPackCache.sbagIndex = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.BackpackDataChange, null);
                    break;
                }
                case 1:
                {
                    _cache.pack.wareHousePackCache.sbagIndex = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.WareHouseDataChange, null);
                    break;
                }
                case 3:
                {
                    _cache.pack.rolePackCache.sbagIndex = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.RolepackDataChange, null);
                    if (Cache.instance.pack.mountsPackCache.equipEdMount && !(Cache.instance.pack.mountsPackCache.equipEdMount == ItemData.nullItemData) && Cache.instance.pack.mountsPackCache.equipEdMount.itemExInfo.mount_equipped_state == 0) 
                    {
                        Cache.instance.pack.mountsPackCache.callEdMount = Cache.instance.pack.mountsPackCache.equipEdMount;
                    }
                    break;
                }
                case 5:
                {
                    _cache.pack.backPackExtendPackCache.sbagIndex = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.BackPackExtendDataChange, null);
                    break;
                }
                case 6:
                {
                    _cache.pack.wareHouseExtendPackCache.sbagIndex = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.WareHouseExtendDataChange, null);
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeStall:
                {
                    _cache.pack.stallPackCache.sbagIndex = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.StallItemsUpdate, null);
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeRunBusiness:
                {
                    _cache.pack.runBusinessPackCache.sbagIndex = loc1;
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeTreasure:
                {
                    _cache.pack.treasurePackCache.sbagIndex = loc1;
                    NetDispatcher.dispatchCmd(ServerCommand.BackPackTreasurePackChange, null);
                    break;
                }
            }
            return;
        }
    }
